package com.hzhjhh.view.manageView.menus.purchase.purchaseOrder;

import java.awt.Rectangle;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.math.BigDecimal;

import javax.swing.JLabel;
import javax.swing.JTextField;

import com.hzhjhh.view.manageView.menus.purchase.PurchaseOrderDialog;

/**
 * 菜单栏初始化-采购-采购表弹出框-采购数量
 * 
 * @author 12083
 *
 */
public class PurchaseNum {

	/**
	 * 标签
	 * 
	 * @return
	 */
	public static JLabel lbInit() {
		JLabel purchaseNum = new JLabel();
		purchaseNum.setText("采购数量");
		purchaseNum.setBounds(37, 59, 75, 21);

		return purchaseNum;
	}
	
	/**
	 * 输入框
	 */
	public static JTextField txfInit(PurchaseOrderDialog stockDialog) {
		JTextField purchaseNum = new JTextField();
		purchaseNum.setText("1");
        purchaseNum.setBounds(new Rectangle(104, 59, 111, 21));
        purchaseNum.addFocusListener(new FocusAdapter() {

			@Override
			public void focusLost(FocusEvent e) {
				BigDecimal purchaseNum = new BigDecimal(stockDialog.getTxfPurchaseNum().getText());
				BigDecimal pricePerOne = new BigDecimal(stockDialog.getTxfPricePerOne().getText());
		        stockDialog.getTxfAmt().setText(purchaseNum.multiply(pricePerOne).toString());
			}
		});
		return purchaseNum;
	}
}
